| Conditions | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | import InvalidInputError from './InvalidInputError'; |
||
| 4 | static dec2bin(number, propositions) { |
||
| 5 | 15 | if (!Number.isInteger(number)) { |
|
| 6 | 6 | throw new InvalidInputError(number, 'number isnt a number'); |
|
| 7 | } |
||
| 8 | |||
| 9 | 9 | if (!Number.isInteger(propositions)) { |
|
| 10 | 4 | throw new InvalidInputError( |
|
| 11 | propositions, |
||
| 12 | 'propositions isnt a number' |
||
| 13 | ); |
||
| 14 | } |
||
| 15 | |||
| 16 | 5 | const binary = parseInt(number, 10).toString(2); |
|
| 17 | |||
| 18 | 5 | return binary.padStart(propositions, '0'); |
|
| 19 | } |
||
| 20 | |||
| 35 |